#!/bin/bash

app_name=GTI
timestamp=`date "+%Y_%m_%d_%H_%M_%S"`

mkdir -p tmp

build=debug

if [ $2 ]; then
  build=$2
fi

case $1 in
  b)
    echo "${build} building..."
    ionic build android --${build}
    ls -l platforms/android/build/outputs/apk/
  ;;
  s)
    target_file=tmp/${app_name}_${timestamp}.apk
    cp platforms/android/build/outputs/apk/android-armv7-${build}.apk ${target_file}
    scp ${target_file} dev.ftbj:/home/site/files/app/Android/
  ;;
  d)
    scp platforms/android/build/outputs/apk/android-armv7-${build}.apk gtig:/mnt/www2016/app/gtig-latest.apk
  ;;
  
esac

# ionic build android --release

# ls -l platforms/android/build/outputs/apk/

# target_file=tmp/${app_name}_${timestamp}.apk

# cp platforms/android/build/outputs/apk/android-armv7-release.apk ${target_file}

# scp ${target_file} dev01.ftbj:/home/site/files/app/Android/
# scp ${target_file} dev01.ftbj:/home/site/files/app/Android/${app_name}_latest.apk

# cordova build android --release

# cordova build android --release -- --keystore="/Volumes/HDD/Develop/Android/keystore/z0y1-release-key.keystore" --storePassword=flyfly --alias=z0y1


# jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1  -tsa https://timestamp.geotrust.com/tsa -keystore /Volumes/HDD/Develop/Android/keystore/z0y1-release-key.keystore platforms/android/build/outputs/apk/android-release-unsigned.apk z0y1

# rm platforms/android/build/outputs/apk/recycler.apk

# /Volumes/HDD/Develop/Android/android-sdk-macosx/build-tools/22.0.1/zipalign -v 4 platforms/android/build/outputs/apk/android-release-unsigned.apk platforms/android/build/outputs/apk/recycler.apk

# scp platforms/android/build/outputs/apk/recycler.apk /Volumes/HDD/Develop/fractal/java7-project/bdTrash/bae/trash_customer/app/files
